/**
 * @description Handle language
 */

import zhCN from 'vue-antd-ui/lib/locale-provider/zh_CN'
import enUS from 'vue-antd-ui/lib/locale-provider/en_US'

// TODO: Judge Language form url or browser or cookie
// Current language
let curLan = 'en'
// Has stored language
const storeLan = localStorage.getItem('vi-lan')
// Judge whether localStorage has vi-lan value
storeLan ? (curLan = storeLan) : localStorage.setItem('vi-lan', curLan)

const locale = curLan
let messages = {}
messages[curLan] = require(`./${curLan}`)
const antdLocale = curLan === 'en' ? enUS : zhCN
const config = { locale, messages }

export { config, antdLocale }
